Skip to content

Replace synchronized method with private lock object in LlamaLoader#230

Merged
bernardladenthin merged 1 commit into
mainfrom
claude/compassionate-allen-3krg9a
Jun 13, 2026
Merged

Replace synchronized method with private lock object in LlamaLoader#230
bernardladenthin merged 1 commit into
mainfrom
claude/compassionate-allen-3krg9a

Conversation

@bernardladenthin

Copy link
Copy Markdown
Owner

Summary

  • Refactored LlamaLoader.initialize() from a synchronized method to use a private lock object (INITIALIZE_LOCK) for synchronization
  • This change addresses SpotBugs warning USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION by preventing untrusted code from acquiring the same intrinsic lock on the public class
  • Keeps the lock private to the class, improving security and encapsulation

Test plan

  • Affected unit / integration tests pass locally
  • CI is green on this branch

Related issues / PRs

Checklist

  • I have read CONTRIBUTING.md and CODE_OF_CONDUCT.md
  • My commits follow Conventional Commits
  • No security-sensitive changes (if there are, I have notified the maintainer privately per SECURITY.md)

https://claude.ai/code/session_01W9s19iveUACGzehJs33Cm9

Synchronize on a private static lock object instead of the LlamaLoader
class's intrinsic lock, so untrusted code that can reach the public
LlamaLoader type cannot acquire the same monitor and interfere with
native-library initialization.
@bernardladenthin bernardladenthin merged commit f63633b into main Jun 13, 2026
8 of 10 checks passed
@bernardladenthin bernardladenthin deleted the claude/compassionate-allen-3krg9a branch June 13, 2026 19:52
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants